<!DOCTYPE html>
<html xmlns:h="http://xmlns.jcp.org/jsf/html" 
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <f:view>
        <f:metadata>
            <f:viewAction action="#{postsBean.init()}"/>
        </f:metadata>
        <h:head>
            <title>Posts</title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        </h:head>
        <h:body>
            <h1>Post List</h1>
            <table class="table" style="border-width: 1px; padding: 5px" border="1px">

                <tr>
                    <th>Title</th><th>Body</th><th>Tags</th><th>Created</th><th></th>
                </tr>

                <ui:repeat value="#{postsBean.posts}" var="p">
                    <tr>
                        <td>
                            #{p.title}
                        </td>
                        <td>#{p.body}</td>
                        <td>#{p.tags}</td>
                        <td>#{p.created}</td>
                        <td>
                            <h:link outcome="edit.xhtml" value="Edit">
                                <f:param name="id" value="#{p.id}"/>
                            </h:link>
                        </td>
                    </tr>
                </ui:repeat>
            </table>
            <p>
            <h:button outcome="edit.xhtml" value=" Add a new Post"></h:button>                
            </p>
        </h:body>
    </f:view>
</html>
